<template>
	<view class="container">
		<view class="success-info">
			<image src="/static/images/success.png" mode="aspectFit"></image>
			<view class="title">支付成功</view>
			<view class="amount">￥{{ orderAmount }}</view>
			<view class="tips">您的订单已支付成功，我们将尽快为您发货</view>
		</view>
		
		<view class="order-info">
			<view class="section-title">订单信息</view>
			<view class="info-item">
				<text class="label">订单编号</text>
				<text class="value">{{ orderId }}</text>
			</view>
			<view class="info-item">
				<text class="label">支付方式</text>
				<text class="value">{{ paymentMethod }}</text>
			</view>
			<view class="info-item">
				<text class="label">支付时间</text>
				<text class="value">{{ payTime }}</text>
			</view>
		</view>
		
		<view class="buttons">
			<view class="btn view-order" @click="viewOrderDetail">查看订单</view>
			<view class="btn back-home" @click="backToHome">返回首页</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			orderId: '',
			orderAmount: 0,
			paymentMethod: '微信支付',
			payTime: ''
		}
	},
	onLoad(options) {
		if (options.orderId) {
			this.orderId = options.orderId
			this.getOrderInfo()
		}
		
		// 设置当前支付时间
		const now = new Date()
		const year = now.getFullYear()
		const month = String(now.getMonth() + 1).padStart(2, '0')
		const day = String(now.getDate()).padStart(2, '0')
		const hours = String(now.getHours()).padStart(2, '0')
		const minutes = String(now.getMinutes()).padStart(2, '0')
		
		this.payTime = `${year}-${month}-${day} ${hours}:${minutes}`
	},
	methods: {
		getOrderInfo() {
			// 模拟获取订单信息
			setTimeout(() => {
				this.orderAmount = 135.6
			}, 500)
		},
		viewOrderDetail() {
			uni.navigateTo({
				url: '/pages/order/detail?orderId=' + this.orderId
			})
		},
		backToHome() {
			uni.switchTab({
				url: '/pages/index/index'
			})
		}
	}
}
</script>

<style lang="scss">
.container {
	padding: 40rpx;
	background-color: #f5f5f5;
	min-height: 100vh;
}

.success-info {
	background-color: #fff;
	border-radius: 16rpx;
	padding: 60rpx 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	margin-bottom: 30rpx;
	
	image {
		width: 120rpx;
		height: 120rpx;
		margin-bottom: 30rpx;
	}
	
	.title {
		font-size: 36rpx;
		color: #333;
		font-weight: bold;
		margin-bottom: 20rpx;
	}
	
	.amount {
		font-size: 56rpx;
		color: #ff5151;
		font-weight: bold;
		margin-bottom: 30rpx;
	}
	
	.tips {
		font-size: 26rpx;
		color: #999;
	}
}

.order-info {
	background-color: #fff;
	border-radius: 16rpx;
	padding: 30rpx;
	margin-bottom: 40rpx;
	
	.section-title {
		font-size: 30rpx;
		color: #333;
		margin-bottom: 30rpx;
		font-weight: bold;
	}
	
	.info-item {
		display: flex;
		justify-content: space-between;
		margin-bottom: 20rpx;
		
		&:last-child {
			margin-bottom: 0;
		}
		
		.label {
			color: #666;
			font-size: 28rpx;
		}
		
		.value {
			color: #333;
			font-size: 28rpx;
		}
	}
}

.buttons {
	display: flex;
	justify-content: space-between;
	
	.btn {
		width: 48%;
		height: 80rpx;
		border-radius: 40rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
	}
	
	.view-order {
		background-color: #fff;
		color: #333;
		border: 1px solid #ddd;
	}
	
	.back-home {
		background-color: #ff5151;
		color: #fff;
	}
}
</style> 